package cn.edu.sdjzu.service.impl;

import cn.edu.sdjzu.dao.TeacherDao;
import cn.edu.sdjzu.entity.Teacher;
import cn.edu.sdjzu.exception.BaseException;
import cn.edu.sdjzu.factory.DaoFactory;
import cn.edu.sdjzu.service.TeacherService;
import cn.edu.sdjzu.util.Condition;
import cn.edu.sdjzu.util.JdbcHelper;
import cn.edu.sdjzu.util.Pagination;

import java.lang.reflect.InvocationTargetException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;

/**
 * @author 刘永渠
 * @project xg22
 * @date 2024/3/28
 */
public class TeacherServiceImpl implements TeacherService {

    @Override
    public Collection<Teacher> findAll(List<Condition> conditionList, Pagination pagination) throws SQLException, BaseException, InvocationTargetException {
        //获得连接以便完成可能的事务操作
        Connection connection = JdbcHelper.getConn();
        Collection<Teacher> teachers = DaoFactory.getDao(TeacherDao.class,"TeacherDaoImpl").findAll
                (connection, conditionList, pagination);
        JdbcHelper.close(connection);
        return teachers;
    }
}
